Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

feature/firmware/src/commonMain/kotlin/org/meshtastic/feature/firmware/ota/FirmwareHashUtil.kt 2d20cd8a4708e2ef66e98d5259f3a97ec93f240a (2d20cd8a) Text, 1.46 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.feature.firmware.ota

Tff7b72import T7ee787okio.ByteString.Companion.toByteString

T8b949e/** KMP utility functions for firmware hash calculation. */
Tff7b72object T56d364FirmwareHashUtil Tb4b4b4{

T8b949e/**
* Calculate SHA-256 hash of raw bytes.
*
* @param data Firmware bytes to hash
* @return 32-byte SHA-256 hash
*/
Tff7b72fun Td2a8ffcalculateSha256BytesTb4b4b4(Te6edf3dataTb4b4b4: Te6edf3ByteArrayTb4b4b4)Tb4b4b4: Te6edf3ByteArray Tff7b72= Te6edf3dataTb4b4b4.Te6edf3toByteStringTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3sha256Tb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3toByteArrayTb4b4b4(Tb4b4b4)

T8b949e/** Convert byte array to lowercase hex string. */
Tff7b72fun Td2a8ffbytesToHexTb4b4b4(Te6edf3bytesTb4b4b4: Te6edf3ByteArrayTb4b4b4)Tb4b4b4: Tffa657String Tff7b72= Te6edf3bytesTb4b4b4.Te6edf3toByteStringTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3hexTb4b4b4(Tb4b4b4)

T8b949e/** Calculate the MD5 hex digest of raw bytes — used to verify a download against a firmware manifest's `md5`. */
Tff7b72fun Td2a8ffcalculateMd5HexTb4b4b4(Te6edf3dataTb4b4b4: Te6edf3ByteArrayTb4b4b4)Tb4b4b4: Tffa657String Tff7b72= Te6edf3dataTb4b4b4.Te6edf3toByteStringTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3md5Tb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3hexTb4b4b4(Tb4b4b4)
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.04s